using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;

namespace SecurityLinkUp
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ScriptService()]
    public class WebServices : System.Web.Services.WebService
    {

       [WebMethod]
       [ScriptMethod(UseHttpGet = true)]
       public string GetUserProfilePopupHTML (string UserID)
       {
            
           try
           {   
               // cast the string to a guid.  if error (by format), will bail out
               Guid guid = new Guid(UserID);

               // get the user
               User u = UserData.GetUser(guid);

               // start creating the HTML for the popup inner text
               string html = "";
               html += "<div align=\"right\"><img src=\"/Images/close.gif\" onclick=\"HidePopup()\" /></div>";
               html += "<table>";
               html += "<tr><td rowspan=\"4\"><img src=\"" + u.picurl + "\">";
               html += "<td>name</td><td>" + u.name;
               if (u.IsRealName)
               {
                   html += "&nbsp;<img src=\"/Images/realname.png\" alt=\"Real Name\">";
               }
               html += "</td></tr>";
               html += "<tr><td>Job title</td><td>" + u.jobtitle + "</td></tr>";
               html += "<tr><td>Company</td><td>" + u.company + "</td></tr>";
               html += "<tr><td>Email</td><td>";
               // print out the email if user allows it
               if (u.AllowEmail)
               {
                   html += "<a href=\"mailto:" + u.email + "\">" + u.email + "</a></td></tr>";
               }
               else
               {
                   html += "<a href=\"\\ContactUser.aspx?userid=" + u.uid + "\">Contact user</a></td></tr>";
               }
               html += "</table>";

               return html;
           }
           catch (Exception ex)
           {
               Log.LogException(ex);
               return "Error!";
           }
       }
    }
}
